#include("../../comm/ListHead.html")
<div class="layui-fluid  layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12 height-auto">
            <div class="layui-card">

                <div class="card-search SearchTable">
                    <p style="float:right">
                        <input type="text" id="keyid" lay-verify="required" placeholder="字典键值" autocomplete="off"
                               class="table-search-text width120">
                        <input type="text" id="title" lay-verify="required" placeholder="标题" autocomplete="off"
                               class="table-search-text width150">
                        <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                            搜索
                        </button>
                    </p>
                    <i class="layui-icon layui-icon-triangle-r"></i>
                    当前位置 > <span id="titles" class="color_green">数据字典列表</span>
                </div>

                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container">
                            <button class="layui-btn layui-btn-sm btn-edit" lay-event="ReloadSysData">清除缓存</button>
                            <button class="layui-btn layui-btn-sm btn-add" lay-event="AddSysData">
                                <i class="layui-icon">&#xe608;</i> 添加数据字典
                            </button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="EditSysData">修改</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-del" lay-event="DelSysData">删除</button>
                        </div>
                    </script>
                    <script type="text/html" id="switchPubTag">
                        <input type="checkbox" lay-skin="switch" name="lock" value="{{d.data_key}}" lay-text="有效|无效" lay-filter="ChangeTag" {{ d.pub_tag ? 'checked' : '' }}>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">

    layui.use(['myTable', 'table', 'form', 'util', 'myTool'], function () {
        var $ = layui.$;
        myTable = layui.myTable, table = layui.table
        form = layui.form, util = layui.util, myTool = layui.myTool;

        tableindex = myTable.render({
            url: 'SysDataListDataApi'
            , title: '数据字典列表'
            , cols: [[
                {type: 'checkbox', width: 36}
                , {field: 'data_key', title: '键值', width: 160}
                , {field: 'sindex', title: '顺序', width: 80, edit: 'text', align: 'center'}
                , {field: 'data_title', title: '标题', width: 180}
                , {field: 'data_source', title: '数据源', width: 150}
                , {field: 'data_desc', title: '备注说明'}
                , {field: 'pub_tag', title: '生效', width: 100, align: 'center', templet: '#switchPubTag'}
            ]]
            , page: true
            , limit: 10
            , editField: {url: 'ModifySysDataFieldApi', key: 'data_key'}
        });

        util.event("lay-event", {
            DoSearch: function () {
                tableindex.reload({
                    where: {
                        like: {data_key: $("#keyid").val(), data_title: $("#title").val()}
                    }
                    , page: {curr: 1}
                });
            },
            DoSearchMore: function () {
                layui.form.render();
                drawer1.open();
            }
        });

        //头工具栏事件
        table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                AddSysData: function () {
                    index = top.layer.open({
                        type: 2, offset: '60px', area: ['800px', '550px'], title: ['添加字典数据', 'font-size:15px;'],
                        content: ["sysdata/AddSysData", 'no'],
                        end: function () {
                            tableindex.reload({});
                        }
                    });
                }
                , EditSysData: function () {
                    myTool.doSingleSelect(table.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '60px', area: ['800px', '550px'], title: ['修改字典[' + data[0].data_title + ']', 'font-size:15px;'],
                            content: ["sysdata/EditSysData?data_key=" + data[0].data_key, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , DelSysData: function () {
                    myTool.doSingleSelect(myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.confirm('你是否确认删除【' + data[0].data_title + '】', {icon: 3, title: '提示', offset: '200px'}, function (index2) {
                            myTool.postMsg("DelSysDataApi", {data_key: data[0].data_key}, function () {
                                top.layer.close(index2);
                                tableindex.reload();
                            });
                        });
                    });
                }
                , ReloadSysData: function () {
                    index = top.layer.confirm('你是否确认清除缓存', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                        myTool.postMsg("ReloadSysDataApi", {}, function () {
                            top.layer.close(index2);
                            //tableindex.reload();
                        });
                    });
                }
            });
        });

        //监听锁定操作
        form.on('switch(ChangeTag)', function (obj) {
            myTool.postMsg("ChangeSysDataTagApi", {data_key: this.value}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
    });
</script>
#include("../../comm/Foot.html")